package msg

const (
	SUCCSE        = 200
	ERROR         = 500
	InvalidParams = 400

	// ERROR_USERNAME_USED code= 1000... 用户模块的错误
	ERROR_USERNAME_USED    = 1001
	ERROR_PASSWORD_WRONG   = 1002
	ERROR_USER_NOT_EXIST   = 1003
	ERROR_TOKEN_EXIST      = 1004
	ERROR_TOKEN_RUNTIME    = 1005
	ERROR_TOKEN_WRONG      = 1006
	ERROR_TOKEN_TYPE_WRONG = 1007
	ERROR_USER_NO_RIGHT    = 1008
	ERROR_USER_NO_PASSWD   = 1009
	ERROR_USER_NO_LOGIN    = 1010
	ERROR_USER_NO_LOGOUT   = 1011

	// ERROR_CMDB_INFO code= 2000... CMDB模块的错误
	ERROR_CMDB_GET_INFO     = 2001
	ERROR_CMDB_GET_WRONG    = 2002
	ERROR_CMDB_DELETE_WRONG = 2003
	ERROR_CMDB_ADD_WRONG    = 2004
	ERROR_CMDB_EDIT_WRONG   = 2005

	ERROR_SCRIPT_GET_INFO     = 3001
	ERROR_SCRIPT_GET_WRONG    = 3002
	ERROR_SCRIPT_DELETE_WRONG = 3003
	ERROR_SCRIPT_ADD_WRONG    = 3004
	ERROR_SCRIPT_EDIT_WRONG   = 3005

	ERROR_job_GET_INFO     = 3101
	ERROR_job_GET_WRONG    = 3102
	ERROR_job_DELETE_WRONG = 3103
	ERROR_job_ADD_WRONG    = 3104
	ERROR_job_EDIT_WRONG   = 3105
)

var codeMsg = map[int]string{
	SUCCSE:        "OK",
	ERROR:         "FAIL",
	InvalidParams: "请求参数错误",

	ERROR_USERNAME_USED:    "用户名已存在！",
	ERROR_PASSWORD_WRONG:   "密码错误",
	ERROR_USER_NOT_EXIST:   "用户不存在",
	ERROR_TOKEN_EXIST:      "TOKEN不存在,请重新登陆",
	ERROR_TOKEN_RUNTIME:    "TOKEN已过期,请重新登陆",
	ERROR_TOKEN_WRONG:      "TOKEN不正确,请重新登陆",
	ERROR_TOKEN_TYPE_WRONG: "TOKEN格式错误,请重新登陆",
	ERROR_USER_NO_RIGHT:    "该用户无权限",
	ERROR_USER_NO_PASSWD:   "未填写用户名或者密码",
	ERROR_USER_NO_LOGOUT:   "登录失败",

	ERROR_CMDB_GET_INFO:     "CMDB已存在",
	ERROR_CMDB_GET_WRONG:    "CMDB不存在",
	ERROR_CMDB_DELETE_WRONG: "CMDB删除失败",
	ERROR_CMDB_ADD_WRONG:    "CMDB新增失败",
	ERROR_CMDB_EDIT_WRONG:   "CMDB修改失败",

	ERROR_SCRIPT_GET_INFO:     "SCRIPT脚本已存在",
	ERROR_SCRIPT_GET_WRONG:    "SCRIPT脚本不存在",
	ERROR_SCRIPT_DELETE_WRONG: "SCRIPT脚本删除失败",
	ERROR_SCRIPT_ADD_WRONG:    "SCRIPT脚本新增失败",
	ERROR_SCRIPT_EDIT_WRONG:   "SCRIPT脚本修改失败",

	ERROR_job_GET_INFO:     "job工单已存在",
	ERROR_job_GET_WRONG:    "job工单不存在",
	ERROR_job_DELETE_WRONG: "job工单删除失败",
	ERROR_job_ADD_WRONG:    "job工单新增失败",
	ERROR_job_EDIT_WRONG:   "job工单修改失败",
}

func GetErrMsg(code int) string {
	return codeMsg[code]
}
